<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      async function promiseWithError(p) {
        try {
          const res = await p
          return {
            err: 0,
            data: res
          }
        } catch (e) {
          return {
            err: 1,
            data: e
          }
        }
      }

      window.onload = function () {
        const p1 = new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve('promise resolve 1')
          }, 1000)
        })

        const p2 = new Promise((resolve, reject) => {
          setTimeout(() => {
            reject('promise resolve 2')
          }, 2000)
        })

        const p3 = new Promise((resolve, reject) => {
          setTimeout(() => {
            reject('promise reject 3')
          }, 3000)
        })

     /*     Promise.all([p1, p2, p3].map(item => promiseWithError(item)))
          .then(res => {
            console.log('resolve:', res)
          })
          .catch(err => {
            console.log('reject:', err)
          })  */
      }
    </script>
  </body>
</html>
